package edu.intprog.egreeting.beans;

public class UserDef {

	private Integer _uid;
	private String _fName;
	private String _lName;
	private String _emailAddr;
	private String _phoneNumber;
	private String _userPassword;
	private String _userPassword2;
	private boolean _isActive;
	
	public UserDef() {
	}

	public Integer get_uid() {
		return _uid;
	}

	public void set_uid(Integer _uid) {
		this._uid = _uid;
	}

	public String get_fName() {
		return _fName;
	}

	public void set_fName(String name) {
		_fName = name;
	}

	public String get_lName() {
		return _lName;
	}

	public void set_lName(String name) {
		_lName = name;
	}

	public String get_emailAddr() {
		return _emailAddr;
	}

	public void set_emailAddr(String addr) {
		_emailAddr = addr;
	}

	public String get_phoneNumber() {
		return _phoneNumber;
	}

	public void set_phoneNumber(String number) {
		_phoneNumber = number;
	}

	public String get_userPassword() {
		return _userPassword;
	}

	public void set_userPassword(String password) {
		_userPassword = password;
	}

	public String get_userPassword2() {
		return _userPassword2;
	}

	public void set_userPassword2(String password2) {
		_userPassword2 = password2;
	}
	
	public boolean is_isActive() {
		return _isActive;
	}

	public void set_isActive(boolean active) {
		_isActive = active;
	}
	
	public String validate() {
		String errorMessage = new String();
		
		if (_fName.length()==0)
		{
			errorMessage = errorMessage + "First name is mandatory.<br />";
		}
		
		if (_lName.length()==0)
		{
			errorMessage = errorMessage + "Last name is mandatory.<br />";
		}
		if (_emailAddr.length()==0)
		{
			errorMessage = errorMessage + "E-Mail address is mandatory.<br />";
		}
			
		if (_emailAddr.matches("(\\w+)@(\\w+\\.)(\\w+)(\\.\\w+)*") == false)
		{
			errorMessage = errorMessage + "E-Mail address must be of a valid form.<br />";
		}

		if (_userPassword.length()==0)
		{
			errorMessage = errorMessage + "Password cannot be empty.<br />";
		}
		
		if (_userPassword.equals(_userPassword2) == false)
		{
			errorMessage = errorMessage + "Passwords should match.<br />";
		}
		
		return errorMessage;	
	}
}
